<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
/* @var $this \Magento\Catalog\Block\Product\Compare\Sidebar */
?>
<?php
$_helper = $this->helper('Magento\Catalog\Helper\Product\Compare');
$_items = $_helper->getItemCount() > 0 ? $_helper->getItemCollection() : null;
$count = $_helper->getItemCount();
?>
<div class="block compare">
    <div class="title">
        <strong><?php echo __('Compare Products') ?></strong>
        <?php if($count > 0): ?>
        <span class="counter qty"><?php echo ($count == 1) ? __('1 item') : __('%1 items',$count) ?></span>
        <?php endif; ?>
    </div>
    <div class="content">
        <?php if($_helper->getItemCount() > 0): ?>
            <ol id="compare-items" class="items compare"
                data-mage-init='{"compareItems":{
                    "removeConfirmMessage":"<?php echo __("Are you sure you would like to remove this item from the compare products?") ?>",
                    "removeSelector":"#compare-items a.action.delete",
                    "clearAllConfirmMessage":"<?php echo __("Are you sure you would like to remove all products from your comparison?") ?>",
                    "clearAllSelector":"#compare-clear-all"
                }}'>
            <?php foreach($_items as $_index => $_item): ?>
            <li class="item">
                <input type="hidden" class="compare-item-id" value="<?php echo $_item->getId() ?>"/>
                <strong class="product name">
                    <a href="<?php echo $this->getProductUrl($_item) ?>">
                        <?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($_item, $_item->getName(), 'name') ?>
                    </a>
                </strong>
                <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');?>
                <a href="#" data-post='<?php echo $compareHelper->getPostDataRemove($_item); ?>'
                   title="<?php echo __('Remove This Item') ?>"
                   class="action delete">
                    <span><?php echo __('Remove This Item') ?></span></a>
            </li>
        <?php endforeach; ?>
    </ol>
    <div class="actions-toolbar">
        <div class="primary">
            <a href="<?php echo $_helper->getListUrl() ?>" class="action compare primary"><span><?php echo __('Compare') ?></span></a>
        </div>
        <div class="secondary">
            <a id="compare-clear-all" href="#" data-post='<?php echo $_helper->getPostDataClearList() ?>' class="action clear">
                <span><?php echo __('Clear All') ?></span>
            </a>
        </div>
    </div>
    <?php else: ?>
        <p class="empty"><?php echo __('You have no items to compare.') ?></p>
        <?php endif; ?>
    </div>
</div>
